<template>
	<!-- 表格-->
	<div class="tableBox">
		<!-- 抬头 -->
		<div class="tableBox_title positionFixed">
			<van-nav-bar title="个人中心"/>
		</div>

		<!-- 登录 -->
		<van-dialog
			title="登录"
			v-model="loginControl"
			show-cancel-button
			:before-close="loginBeforeClose"
			>
			<van-field
				v-model="phone"
				label="手机号"
				placeholder="请输入手机号"
			/>
			<van-field
				v-model="password"
				type="password"
				label="密码"
				placeholder="请输入密码"
			/>
		</van-dialog>

		<!-- 更换守护 -->
		<van-dialog
			title="设置守护"
			v-model="shouhuControl"
			show-cancel-button
			:before-close="shouhuBeforeClose"
			>
			<van-field
				v-model="recommend"
				label="守护ID"
				placeholder="请输入守护者ID(推荐码)"
			/>
		</van-dialog>

		<!-- 分时查询 -->
		<van-popup class="showPopup" v-model="showFenshiOrdersPop" position="right">
			<div class="tableBox_title">
				<van-nav-bar title="分时查询" left-arrow @click-left="showFenshiTab"/>
			</div>
			<p class="centers">查询选定时间后二十分钟的订单,可查任意过去时订单！</p>

			<!-- 时间控件 -->
			<van-datetime-picker
			v-model="currentDate"
			type="datetime"
			:min-date="minDate"
			:max-date="maxDate"
			@confirm = "getTkOrderbyTb"
			@cancel = "showFenshiTab"
			/>

			<div class="optionalList" v-for="(items,index) in fenshiOrders" :key="index" >
				<!-- <div class="optionalListLeft">
					<img src="https://img.alicdn.com/bao/uploaded/i4/720853322/O1CN011aPWBd6ZQBggcct_!!720853322.jpg"/>
				</div> -->
				<div class="optionalListRight" @click="convertFunc(items.num_iid)">
					<p class="optionalListRight-title">
						{{items.item_title}}
					</p>
					<p class="optionalListRight-price">
						<span>消费金额: &yen;{{items.alipay_total_price}}</span>
						<span class="floatRight">预估收益: &yen;{{items.pub_share_pre_fee}}</span>
					</p>
					<p class="optionalListRight-PresentId">
						<span>提成:&nbsp;<span>{{items.total_commission_rate}}%</span></span>
						<span class="floatRight">状态:&nbsp;{{items.tk_status}}</span>
					</p>
					<p class="optionalListRight-Presentdata">
						<span>{{items.click_time}}</span>&nbsp; 创建
					</p>
					<p class="optionalListRight-Presentdata">
						订单号： <span>{{items.trade_id}}</span>
					</p>
				</div>
			</div>
		</van-popup>

		<!-- 订单查询 -->
		<van-popup class="showPopup" v-model="showOrdersPop" position="right">
			<div class="tableBox_title">
				<van-nav-bar title="订单列表" left-arrow @click-left="showListTabBack"/>
			</div>
			<p class="centers">订单范围为昨日之前所有订单（已提现除外）！</p>
			<div class="optionalListBox" v-if="selfOrder.orderdetails.orderList.length">
				<!-- 每个元素的两侧间隔相等 -->
				<van-row type="flex" justify="space-around">
					<van-col span="12">
						<span class="vantCols">
							订单比数(比)：{{selfOrder.orderdetails.alloOrders}}
						</span>
					</van-col>
					<van-col span="12">
						<span class="vantCols">
							有效订单(比)：{{selfOrder.orderdetails.validOrders}}
						</span>
					</van-col>
					<van-col span="12">
						<span class="vantCols">
							订单预估(滴)：{{selfOrder.orderdetails.estimate_m}}
						</span>
					</van-col>
					<van-col span="12">
						<span class="vantCols">
							结算收入(滴)：{{selfOrder.orderdetails.settlement_m}}
						</span>
					</van-col>
				</van-row>

				<van-tabs swipeable>
					<van-tab title="全部">
						<div class="optionalList" v-for="(items,index) in rangeOrders" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span></span> <!-- 提成:&nbsp;<span>{{items.income_p}}</span> -->
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
					<van-tab title="已付款">
						<div class="optionalList" v-for="(items,index) in selfOrder.ordersYfk" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>提成:&nbsp;<span>{{items.income_p}}</span></span>
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
					<van-tab title="已结算">
						<div class="optionalList" v-for="(items,index) in selfOrder.ordersYjq" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>提成:&nbsp;<span>{{items.income_p}}</span></span>
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
					<van-tab title="已失效">
						<div class="optionalList" v-for="(items,index) in selfOrder.ordersYsx" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>提成:&nbsp;<span>{{items.income_p}}</span></span>
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
				</van-tabs>
			</div>

			<!-- 分页 -->
			<div v-if="totalNum">
				<van-pagination 
				v-model="currentPage" 
				:total-items="totalNum" 
				:items-per-page = "10"
				:show-page-size="3" 
				force-ellipses
				@change = "onSupSearch(false)"
				/>
			</div>
		</van-popup>

		<!-- 分级订单 -->
		<van-popup class="showPopup" v-model="showOrdersCliPop" position="right">
			<div class="tableBox_title">
				<van-nav-bar title="分级订单" left-arrow @click-left="showListTabCliBack"/>
			</div>
			<p class="centers">订单范围为昨日之前所有订单（已提现除外）！</p>
			<div class="optionalListBox" v-if="fsOrders.orderdetails.orderList.length">
				<!-- 每个元素的两侧间隔相等 -->
				<van-row type="flex" justify="space-around">
					<van-col span="12">
						<span class="vantCols">
							订单比数(比)：{{fsOrders.orderdetails.alloOrders}}
						</span>
					</van-col>
					<van-col span="12">
						<span class="vantCols">
							有效订单(比)：{{fsOrders.orderdetails.validOrders}}
						</span>
					</van-col>
					<van-col span="12">
						<span class="vantCols">
							订单预估(滴)：{{fsOrders.orderdetails.estimate_m}}
						</span>
					</van-col>
					<van-col span="12">
						<span class="vantCols">
							结算收入(滴)：{{fsOrders.orderdetails.settlement_m}}
						</span>
					</van-col>
				</van-row>

				<van-tabs swipeable>
					<van-tab title="全部">
						<div class="optionalList" v-for="(items,index) in rangeFsOrders" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>来源: **{{items.platformName}}</span> <!-- &nbsp;<span>{{items.income_p}}</span> -->
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<!-- <p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p> -->
							</div>
						</div>
					</van-tab>
					<van-tab title="已付款">
						<div class="optionalList" v-for="(items,index) in fsOrders.ordersYfk" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>提成:&nbsp;<span>{{items.income_p}}</span></span>
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
					<van-tab title="已结算">
						<div class="optionalList" v-for="(items,index) in fsOrders.ordersYjq" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>提成:&nbsp;<span>{{items.income_p}}</span></span>
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
					<van-tab title="已失效">
						<div class="optionalList" v-for="(items,index) in fsOrders.ordersYsx" :key="index" @click="convertFunc(items.commodityId)">
							<div class="optionalListRight">
								<p class="optionalListRight-title">
									{{items.commodity}}
								</p>
								<p class="optionalListRight-price">
									<span>消费金额: &yen;{{items.payment}}</span>
									<span class="floatRight">预估收益: &yen;{{items.estimate_m}}</span>
								</p>
								<p class="optionalListRight-PresentId">
									<span>提成:&nbsp;<span>{{items.income_p}}</span></span>
									<span class="floatRight">状态:&nbsp;{{items.state}}</span>
								</p>
								<p class="optionalListRight-Presentdata">
									<span>{{items.clickTime}}</span>&nbsp; 创建
								</p>
								<p class="optionalListRight-Presentdata">
									订单号： <span>{{items.trade_id}}</span>
								</p>
							</div>
						</div>
					</van-tab>
				</van-tabs>
			</div>
		</van-popup>

		<!-- 提现 -->
		<van-popup class="showPopup" v-model="showTxOrdersPop" position="right">
			<div class="tableBox_title">
				<van-nav-bar title="资产转化" left-arrow @click-left="showTxOrdersPopFunc"/>
			</div>
			<p class="centers"> 规则会随着系统迭代更新，为了避免争议请
				<router-link to="/rules">先查看规则</router-link>!
			</p>

			<van-row type="flex" justify="space-around">
				<van-col span="12">
					<span class="vantCols">
						可转化订单(比)：{{ordersAllYjq.length}}
					</span>
				</van-col>
				<van-col span="12">
					<span class="vantCols">
						可转化资产(滴)：{{settlement_m}}
					</span>
				</van-col>
			</van-row>

			<van-collapse van-collapse v-model="tixianZhedie" accordion>
				<van-collapse-item title="选择转化订单" name="1">
					<van-checkbox-group v-model="ordersYjqChencked">
					<div class="optionalList" v-for="(items,index) in ordersAllYjq" :key="index" >
						<div class="optionalListRight">
							<p class="optionalListRight-title">
								<van-checkbox :name="items.trade_id" ref="checkboxes" />
								{{items.commodity}}
							</p>
							<p class="optionalListRight-price">
								<span>消费金额: &yen;{{items.payment}}</span>
								<span class="floatRight">收益: {{items.estimate_m}} 滴</span>
							</p>
							<p class="optionalListRight-PresentId">
								<span v-if="!items.isSelf">来源:&nbsp;<span>**{{items.platformName}}</span></span>
								<span class="floatRight">状态:&nbsp;{{items.state}}</span>
							</p>
							<p class="optionalListRight-Presentdata">
								<span>{{items.clickTime}}</span>&nbsp; 创建
							</p>
							<p class="optionalListRight-Presentdata" v-if="items.isSelf">
								订单号： <span>{{items.trade_id}}</span>
							</p>
						</div>
					</div>
					</van-checkbox-group>
				</van-collapse-item>
			</van-collapse>

			<van-row type="flex" justify="space-around">
				<van-col span="12">
					<span class="vantCols">
						已选择订单(比)：{{ordersYjqChencked.length}}
					</span>
				</van-col>
				<van-col span="12">
					<span class="vantCols">
						已选择转化资产(滴)：{{ordersYjqCompt}}
					</span>
				</van-col>
			</van-row>
			<div class="submintCont">
				<van-button plain type="primary" @click="transTxFunc">提交转化申请</van-button>
			</div>
			
		</van-popup>

		<!-- 提现记录 -->
		<van-popup class="showPopup" v-model="showTxHistoryPop" position="right">
			<div class="tableBox_title">
				<van-nav-bar title="转化记录" left-arrow @click-left="showTxHistoryPopFunc"/>
			</div>

			<div class="ordersCont" v-for="(items,index) in txHistoryList" :key="index">
				<van-cell-group>
					<van-cell title="提交时间" :value="items.xtDate" />
				</van-cell-group>

				<van-cell-group>
					<van-cell title="转化数额" :value="items.txMoney" />
				</van-cell-group>

				<van-cell-group>
					<van-cell title="进度" :value="items.states" />
				</van-cell-group>
			</div>
			
		</van-popup>

		<!-- 主题页面 -->
		<div class="userCont">
			<span class="userHeads">
				<img src="http://qiniu.lingyouhui.vip/user/userHeads3.jpg" alt="头像" v-if="loginMessage.isLogin">
				<img src="https://cmsstatic.ffquan.cn//wap_new/user/images/integral/user.png?v=201912112143" alt="头像" v-else>
			</span>
			<span class="userNames" v-if="loginMessage.isLogin">
				<b class="phone"> {{loginMessage.name}} </b>
				<b class="code"> ID: {{loginMessage.aliasId}} </b>
			</span>
			<div v-else> 
				<span class="userLogins" @click="loginControlFunc">
					登 录
				</span>
				<span class="userLogins" @click="jumpRouter('/apply')">
					成为粉丝
				</span>
			</div>
		</div>
		
		<!-- 守护 -->
		<div class="shouhuren">
			<van-cell-group v-show="!loginMessage.isLogin">
				<van-cell title="设置守护" value=">" @click="shouhuControlFunc" />
			</van-cell-group>

			<van-cell-group>
				<van-cell title="守护ID" :value="recommend" />
			</van-cell-group>

			<van-cell-group>
				<van-cell title="分享链接" value="点击复制" @click="shareUrlFunc"/>
			</van-cell-group>

			<van-cell-group>
				<van-cell title="邀请粉丝" value="点击复制" @click="shareApplyFunc"/>
			</van-cell-group>
		</div>

		<!-- 订单系统 登陆后查看 -->
		<div class="ordersCont" v-show="loginMessage.isLogin">
			<van-cell-group>
				<van-cell title="我的返利" value=">" @click="showOrdersPopFunc"/>
			</van-cell-group>
			<van-cell-group>
				<van-cell title="粉丝返利" value=">" @click="showOrdersPopCliFunc"/>
			</van-cell-group>
			<van-cell-group>
				<van-cell title="分时查询" value=">" @click="showFenshiTab"/>
			</van-cell-group>
			<van-cell-group>
				<van-cell title="资产转化" value=">" @click="showAllOrdersPopFunc"/>
			</van-cell-group>
			<van-cell-group>
				<van-cell title="转化记录" value=">" @click="transTxHistoryFunc"/>
			</van-cell-group>

			<van-cell-group>
				<van-cell title="退出登录" value=""  @click="logoutFunc"/>
			</van-cell-group>
		</div>
	</div>
</template>

<script>
import storages from "@/utils/storage.js";

	export default {
		data() {
			return {
				loginMessage: {
					isLogin: false,
					name: '',
					aliasId: '',
					phone: '',
				},
				loginControl: false,
				shouhuControl: false,
				minDate: new Date(2018, 11, 28),
				maxDate: new Date(),
				currentDate: new Date(),
				shname: '**主',
				selfOrder: {
					orderdetails: {
						orderList: []
					},
					ordersYfk: [],
					ordersYjq: [],
					ordersYsx: [],
				},
				fsOrders: {
					orderdetails: {
						orderList: []
					},
					ordersYfk: [],
					ordersYjq: [],
					ordersYsx: [],
				},
				settlement_m: 0,
				ordersAllYjq: [],
				ordersYjqChencked: [],
				fenshiOrders: [],
				txHistoryList: [],
				recommend: '',
				phone: '',
				password: '',
				currentPage: 1,
				totalNum: 0,
				tixianZhedie: 0,
				showFenshiOrdersPop: false,
				showOrdersPop: false,
				showOrdersCliPop: false,
				showTxOrdersPop: false,
				showTxHistoryPop: false,
			};
		},
		components: {
		},
		methods: {
			// 返回某一页
			jumpRouter(uri,querys) {
				this.$router.push({path: uri,query:querys})
			},
			// 返回上一页
			onClickLeft(){
				this.$router.go(-1)
			},
			shareUrlFunc() {
				let _this = this;
				let shareUrl = window.location.origin + '/?p=' + this.recommend;
				this.$copyText(shareUrl).then(function (e) {
					_this.$toast('复制成功');
				}, function (e) {
					_this.$toast('复制失败！');
				})
			},
			shareApplyFunc() {
				let _this = this;
				let shareUrl = window.location.origin + '/apply?p=' + this.recommend;
				this.$copyText(shareUrl).then(function (e) {
					_this.$toast('复制成功');
				}, function (e) {
					_this.$toast('复制失败！');
				})
			},
			getRecommend() {
				let recommender = storages.getItem("recommender", {
					type: "local"
				});
				if (recommender) {
					this.recommend = recommender;
				}
			},
			rmRecommend() {
				let p = this.recommend;
				storages.setItem("recommender", p, {
					type: "local"
				});
				this.getSHname();
			},
			getSHname() {
				let aliasId = storages.getItem("recommender", {
					type: "local"
				});
				this.service.getSHname({
					aliasId: aliasId || ''
				}).then(res => {
					if (res.code == 1) {
						if(res.data){
							this.shname = '**' + res.data.name;
							this.$toast('守护: ' + this.shname);
						}
					}
				})
			},
			convertFunc(num_iid){
				num_iid = num_iid + '';
				let routeData = this.$router.resolve({
					name: "coupon",
					query: {num_iids:num_iid}
				});
				window.open(routeData.href, '_blank');
			},
			showFenshiTab() {
				let tokens = storages.getItem("token", {
					type: "local"
				});
				if (tokens) {
					this.showFenshiOrdersPop = !this.showFenshiOrdersPop;
				}else{
					this.$dialog.alert({
						title: '提示',
						message: '请登录后进行查询！'
					});
				}
			},
			// 订单控制
			showListTabBack(){
				this.showOrdersPop = !this.showOrdersPop;
			},
			// 分级订单
			showListTabCliBack(){
				this.showOrdersCliPop = !this.showOrdersCliPop;
			},
			// 提现控制
			showTxOrdersPopFunc(){
				this.showTxOrdersPop = !this.showTxOrdersPop;
			},
			// 体现记录控制
			showTxHistoryPopFunc(){
				this.showTxHistoryPop = !this.showTxHistoryPop;
			},
			// 自身订单
			showOrdersPopFunc(dot) {
				if (this.loginMessage.isLogin) {
					// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.service.getTkOrder({}).then(res => {
						if (res.code == 1) {
							loadToast.clear();
							if(res.data.ok){
								this.showOrdersPop = true;
								
								this.selfOrder.orderdetails = res.data;
								let orderList = res.data.orderList;
								this.selfOrder.ordersYfk = [];
								this.selfOrder.ordersYjq = [];
								this.selfOrder.ordersYsx = [];
								for (const key in orderList) {
									if (orderList[key].state == "订单付款") {
										this.selfOrder.ordersYfk.push(orderList[key])
									}else if(orderList[key].state == "订单结算"){
										this.selfOrder.ordersYjq.push(orderList[key])
									}else if(orderList[key].state == "订单失效"){
										this.selfOrder.ordersYsx.push(orderList[key])
									}
								}

							}else{
								this.$dialog.alert({
									message: res.data.message
								});
							}
						}
					})	
				}else{
					this.showOrdersPop = false;
					this.$dialog.alert({
						message: '请登录后进行查询！'
					});
				}
			},
			// 分级订单
			showOrdersPopCliFunc() {
				if (this.loginMessage.isLogin) {
					// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.service.getFSOrder({}).then(res => {
						if (res.code == 1) {
							loadToast.clear();
							if(res.data.ok){
								this.showOrdersCliPop = true;

								this.fsOrders.orderdetails = res.data;
								let orderList = res.data.orderList;
								this.fsOrders.ordersYfk = [];
								this.fsOrders.ordersYjq = [];
								this.fsOrders.ordersYsx = [];
								for (const key in orderList) {
									if (orderList[key].state == "订单付款") {
										this.fsOrders.ordersYfk.push(orderList[key])
									}else if(orderList[key].state == "订单结算"){
										this.fsOrders.ordersYjq.push(orderList[key])
									}else if(orderList[key].state == "订单失效"){
										this.fsOrders.ordersYsx.push(orderList[key])
									}
								}

							}else{
								this.$dialog.alert({
									message: res.data.message
								});
							}
						}
					})	
				}else{
					this.showOrdersCliPop = false;
					this.$dialog.alert({
						message: '请登录后进行查询！'
					});
				}

			},
			// 全部订单处理
			showAllOrdersPopFunc() {
				if (this.loginMessage.isLogin) {
					// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.showTxOrdersPop = true;
					this.settlement_m = 0;
					this.ordersAllYjq = [];
					this.ordersYjqChencked = [];

					this.service.getTkOrder({}).then(res => {
						if (res.code == 1) {
							if(res.data.ok){
								let orders = res.data.orderList; 
								for (const key in orders) {
									if(orders[key].state == "订单结算"){
										orders[key].isSelf = true
										this.ordersAllYjq.push(orders[key])
										this.ordersYjqChencked.push(orders[key].trade_id)
									}
								}
								this.settlement_m += parseFloat(res.data.settlement_m);
							}
						} 
					})

					this.service.getFSOrder({}).then(res => {
						if (res.code == 1) {
							loadToast.clear();
							if(res.data.ok){
								let orders = res.data.orderList; 
								for (const key in orders) {
									if(orders[key].state == "订单结算"){
										orders[key].isSelf = false
										this.ordersAllYjq.push(orders[key])
										this.ordersYjqChencked.push(orders[key].trade_id)
									}
								}
								this.settlement_m += parseFloat(res.data.settlement_m);
							}
						}
					})	
				}else{
					this.showTxOrdersPop = false;
					this.$dialog.alert({
						message: '请登录后进行查询！'
					});
				}

			},
			// 分时查询
			getTkOrderbyTb() {
				if (this.loginMessage.isLogin) {
					// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.service.scOrderGet({
						start_time: this.currentDate.getTime()
					}).then(res => {
						if (res.code == 1) {
							loadToast.clear();
							if(res.data.ok){
								this.fenshiOrders = res.data.orderList;
								if (!this.fenshiOrders.length) {
									this.$toast('您在该时段没有订单！');
								}
							}else{
								this.$dialog.alert({
									message: res.data.message
								});
							}
						}
					})	
				}
			},
			// 转化
			transTxFunc() {
				let money = 0;
				let orders = '';
				for(let items in this.ordersAllYjq){
					if (this.ordersYjqChencked.indexOf(this.ordersAllYjq[items].trade_id) != '-1') {
						money += this.ordersAllYjq[items].estimate_m;
						orders += this.ordersAllYjq[items].trade_id + ',';
					}
				}
				if(money >= 100 && orders.length){
					money = money.toFixed(2) + ''
					// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.service.orderTransTx({
						money: money,
						orders: orders.substr(0,orders.length - 1)
					}).then(res => {
						loadToast.clear();
						if (res.data.result.ok) {
							this.showTxOrdersPopFunc();
							this.$dialog.alert({
								message: '转化申请提交成功，请联系管理员！'
							});
						}else{
							this.$dialog.alert({
								message: res.data.message
							});
						}
					})
				}else{
					this.$dialog.alert({
						message: '资产不足转化，如需强行转化请联系管理员！'
					});
				}
			},
			//转化记录
			transTxHistoryFunc(){
				this.showTxHistoryPopFunc();
				// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.service.orderTransHistory().then(res => {
						loadToast.clear();
						if (res.data.ok) {
							this.txHistoryList = res.data.historyList
							for(let items in this.txHistoryList){
								if (this.txHistoryList[items].states == 0) {
									this.txHistoryList[items].states = '已接收'
								}
								if (this.txHistoryList[items].states == 1) {
									this.txHistoryList[items].states = '已审核'
								}
								if (this.txHistoryList[items].states == 2) {
									this.txHistoryList[items].states = '已完成'
								}
							}
						}else{
							this.$dialog.alert({
								message: res.data.message
							});
						}
					})

			},
			loginControlFunc() {
				this.loginControl = !this.loginControl
			},
			shouhuControlFunc() {
				this.shouhuControl = !this.shouhuControl
			},
			loginBeforeClose(action, done) {
				if (action === 'confirm') {
					if (this.phone.length == '11' && this.password) {
					// 加载遮罩
					let loadToast = this.$toast.loading({
						mask: true,
						message: '加载中...',
						duration: '30000'
					});
					this.service.getUserInfo({
						phone: this.phone,
						password: this.password
					}).then(res => {
						loadToast.clear();
						done();
						if (res.data.ok) {
							res.data.data.isLogin = true;
							this.loginMessage = res.data.data;
							// 信息存储
							storages.setItem("token", res.data.data.token, {
								type: "local"
							});
							storages.setItem("loginMessage", res.data.data, {
								type: "local"
							});
							// 设置登录人为守护
							storages.setItem("recommender", this.loginMessage.aliasId, {
								type: "local"
							});
							this.getRecommend()
						}else{
							this.$dialog.alert({
								message: res.data.message
							});
							this.loginControlFunc();
						}
					})
				}
					
				} else {
					done();
				}
			},
			logstates() {
				let tokens = storages.getItem("token", {
					type: "local"
				});
				
				if(tokens&&tokens!='null'&&tokens!='undefind'){
					let loginMessage = storages.getItem("loginMessage", {
						type: "local"
					});
					this.loginMessage = loginMessage;
				}else{
					this.loginMessage.isLogin = false;
				}
			},
			logoutFunc() {
				storages.setItem("token", null, {
					type: "local"
				});
				this.logstates();
			},
			shouhuBeforeClose(action, done) {
				if (action === 'confirm') {
					this.rmRecommend();
					done();
				} else {
					done();
				}
			},
		},
		mounted() {
			this.logstates();
			this.getRecommend();
		},
		computed: {
			rangeOrders: function() {
				return this.selfOrder.orderdetails.orderList.sort((a,b)=>{
					a = new Date(a.clickTime).getTime();
					b = new Date(b.clickTime).getTime();
					return b-a;
				});
			},
			rangeFsOrders: function() {
				return this.fsOrders.orderdetails.orderList.sort((a,b)=>{
					a = new Date(a.clickTime).getTime();
					b = new Date(b.clickTime).getTime();
					return b-a;
				});
			},
			ordersYjqCompt: function() {
				let money = 0;
				for(let items in this.ordersAllYjq){
					if (this.ordersYjqChencked.indexOf(this.ordersAllYjq[items].trade_id) != '-1') {
						money = parseFloat(this.ordersAllYjq[items].estimate_m) + money;
					}
				}
				return money.toFixed(2)
			}
		}
	};
</script>
<style scoped lang="scss">
	.tableBox{
		padding-top: 100px;
		width: 100%;

		.positionFixed{
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
		}
		
		.userCont{
			width: 100%;
			height: 200px;
			background: #fff;
			.userHeads{
				display: block;
				width: 150px;
				height: 200px;
				float: left;
				line-height: 200px;
				padding:0 30px;
				img{
					vertical-align: middle;
					width: 100%;
					height: auto;
					border-radius: 50%;
				}
			}
			.userNames{
				display: block;
				float: left;
				font-size: 36px;
				padding-left: 60px;
				line-height: 200px;
				b{
					display: block;
					width: 100%;
					height: 60px;
					line-height: 60px;
				}
				.phone{
					margin-top: 40px;
				}
			}

			.userLogins{
				display: inline-block;
				padding: 0 30px;
				font-size: 36px;
				height: 80px;
				margin: 60px 20px 0 20px;
				line-height:80px;
				background: #D2D3BD;
				color: #fff;
				font-size: 32px;
				border-radius: 50px;
			}

		}

		.submintCont{
			margin-top: 20px;
			text-align: center;
		}

		.showPopup{
			width: 100%;
			height: 100%;
			overflow-y: auto;
		}

		.vantCols{
			line-height: 80px;
			font-size: 30px;
			padding-left: 20px;
		}
		.van-button{
			font-size: 28px;
		}
		.centers{
			line-height: 60px;
			font-size: 24px;
			text-align: center;
			background: #eaeaea;
		}
		
		.optionalList{
			display: flex;
			display: -webkit-flex;
			flex-flow: row nowrap;
			justify-content: space-around;
			margin-bottom: 8px;
			padding:10px 20px 5px;
			background: #fff;
			.optionalListLeft{
				width: 320px;
				margin-right:20px;
			}
			.optionalListLeft img{
				max-width: 320px;
				width: 100%;
				height: auto;
			}
			.optionalListRight{
				width: 100%;
				display: block;
				padding-bottom: 6px;
				border-bottom: 2px dotted #cccccc;
				p{
					line-height: 48px;
					span{
						line-height: 45px;
					}
				}
				.optionalListRight-title{
					font-size:26px;
					line-height: 35px;
					color:#333;
					margin-top: 5px;
				}
				.optionalListRight-Presentdata{
					font-size:24px;
					color:#999;
					line-height: 36px;
				}
				.optionalListRight-PresentId{
					font-size:24px;
					color:#999;
					span{
						font-size:24px;
					}
					.floatRight{
						float:right;
						color:#e86809;
					}
				}
				.optionalListRight-price{
					margin-top: 10px;
					font-size:24px;
					color:#666;
					.floatRight{
						float:right;
						color:#e86809;
					}
				}
			}
		}

		.ordersCont{
			margin-top: 50px;
		}

		.posBottom {
			box-sizing: border-box;
			padding: 10px 30px;
			width: 100%;
			height: auto;
			background: #cccccc;
			text-align: center;
			.valText {
				width: 86%;
				height: 60px;
				border-radius: 10px;
				text-indent: 10px;
				border: none;
				font-size: 26px;
				text-align: center;
			}
		}
	}
</style>
